//
// Created by wenyaxi on 24-11-1.
//
#include <common.h>

class Solution {
public:
    int res = INT_MIN;

    int maxPathSum(TreeNode *root) {
        maxScore(root);
        return res;
    }

    int maxScore(TreeNode *root) {
        if (root == nullptr) {
            return 0;
        }
        int cur_score = root->val;
        int left_child_score = max(maxScore(root->left), 0);
        int right_child_score = max(maxScore(root->right), 0);

        int cur_max_score = cur_score + left_child_score + right_child_score;
        res = max(res, cur_max_score);
        return cur_score + max(left_child_score, right_child_score);
    }
};

int main(int argc, char *argv[]) {
    //[1,2,3]
    //[-10,9,20,null,null,15,7]

    return 0;
}
